<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      layout:decorate="layout">
<head>
    <title>home</title>
    <script type="text/javascript" src="../../static/js/charByte.js"></script>
    <script charset="utf-8" src="../../static/js/kindeditor/kindeditor.js"></script>
    <script charset="utf-8" src="../../static/js/kindeditor/lang/zh_CN.js"></script>
    <script type="text/javascript">
        var editor1;
        KindEditor.ready(function(K) {
            editor1 = K.create('textarea[name="content"]', {
                items : [
                    'undo', 'redo', '|', 'cut', 'copy', 'paste','justifycenter',
                    'plainpaste', 'wordpaste', '|', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', 'image',
                    'formatblock', 'fontsize', '|', 'forecolor', 'hilitecolor', 'underline', 'strikethrough', 'lineheight', 'removeformat',
                    'hr', 'link', 'unlink', '|', 'source'
                ],
                newlineTag : "p",
                cssPath : '../../static/js/kindeditor/plugins/code/prettify.css',
                uploadJson : '/upload/image.htm',
                fileManagerJson : '/upload/image.htm',
                allowFileManager : true,
                resizeType : 0,
                allowImageRemote : false,
                afterCreate : function() {
                    var self = this;
                    K.ctrl(document, 13, function() {
                        self.sync();
                        //document.forms['dataForm'].submit();
                    });
                    K.ctrl(self.edit.doc, 13, function() {
                        self.sync();
                        //document.forms['dataForm'].submit();
                    });
                },
                afterBlur : function() {
                    this.sync(); //表示当失去焦点时  将内容同步到textare中去
                }
            });
            K('.picnew').click(function (e) {
                var con=editor1.text();

                if(con==null || $.trim(con)==""){
                    alert("请输入内容");
                    return false;
                }else{
                    if(editor1.count('text')>1000) {
                        alert("内容过长");
                        return false;
                    }else{
//                        $("#loadingDiv").show();
                        $.ajax({
                            cache: false,
                            type: "POST",
                            url:'../../admin/commit',
                            data:$('#insertOrUpdate').serialize(),//form id
                            async: false,
                            error: function(request) {
//                                $("#loadingDiv").hide();
                                alert("保存失败");
                            },
                            success: function(data) {
//                                $("#loadingDiv").hide();
                                if(data) {
                                    alert("保存成功");
                                } else {
                                    alert("保存失败");
                                }
                            }
                        });
                    }
                }
            });
            //prettyPrint();
        });

    </script>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .bg {
            font-size: 35px;
            line-height: 40px;
            font-family: "微软雅黑";
            text-shadow: 0px 1px 3px #438EB9;
            color: #438EB9;
        }
        .btn-scroll-up {
            display: none;
        }
        .title{
            padding: 12px 0 17px 40px;
            border-bottom: 1px solid #F4F4F4;
        }
        .title span{
            color: #62a8d1;
            font-size: 1.4rem;
            font-weight: 500;
        }
        .index{
            width: 100%; padding-left: 16px;
            height: 40px;
            line-height: 40px;
            background-color: #F5F5F5;
        }
        .index a{
            display: block;
            font-size: 14px;
            color:#0000ff;
            width: 50px;
            float: left;
        }
        .index span{
            font-size: 22px;
            font-weight: 500;
            margin:-3px 0 0 -12px;
            float: left;
            color: #0000ff;
        }

        .contenter{
            float: left; margin-right: 10px;
        }
        .contenter span{
            font-size: 0.7rem;
            font-weight: 500;
        }
        .sub{
            margin-top: 8px; overflow: hidden;width: 100%;text-align: right;
        }
        .sub input{
            width: 100px;
            height: 32px;
            margin: 32px 376px 0 0;
        }
    </style>
</head>
<body>
<!--<h1 layout:fragment="header">Messages : View all</h1>-->
<div layout:fragment="content">
    <div class="box-header with-border">
        <h3 class="box-title">承诺书动态配置</h3>
    </div>
    <form class="form-horizontal" id="insertOrUpdate" name="insertOrUpdate" action="" method="post" >
        <div class="box-body">
            <input type="hidden" id="id" name="id" th:value="${commit.id}">
            <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
            <div style="width: 100%; overflow: hidden; margin-top: 8px;">
                <div class="contenter">
                    <!--<span>内 容:</span>-->
                </div>
                <textarea  id="con" name="content" rows="4" style="resize: none; height: 300px; font-size: 12px; width: 750px;; overflow: auto;" th:text="${commit.content}"></textarea>
            </div>
            <div class="form-group col-md-3 right-button" style="margin-top:20px;">
                <input type="button" style="" class="picnew btn btn-success right-button" value="提 交"/>
            </div>
        </div>
    </form>
</div>
</body>
</html>